package yh.plugins.workflow;

import java.sql.Connection;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import yh.core.data.YHRequestDbConn;
import yh.core.funcs.workflow.data.YHFlowRunData;
import yh.core.funcs.workflow.util.YHFlowRunUtility;
import yh.core.funcs.workflow.util.YHIWFPlugin;
import yh.core.global.YHBeanKeys;

/**
 * 工作流插件接口
 * @author jpt
 *
 */
public class GDContentPlugin_2 extends BasePlugin implements YHIWFPlugin{
  /**
   * 节点执行前执行   * @param request
   * @param response
   * @return
   * @throws Exception 
   */
  public String before(HttpServletRequest request, HttpServletResponse response) throws Exception {
   return null;
  }
  /**
   * 节点执行完毕执行
   * @param request
   * @param response
   * @return
   */
  public String after(HttpServletRequest request, HttpServletResponse response) throws Exception {
    //System.out.println("------------结束啦");
	  
	  try {
	      YHRequestDbConn requestDbConn = (YHRequestDbConn) request
	          .getAttribute(YHBeanKeys.REQUEST_DB_CONN_MGR);
	      Connection conn = requestDbConn.getSysDbConn();
	      //流程id
	      String flowIdStr = request.getParameter("flowId");
	      //工作id即流水号
	      String runIdStr = request.getParameter("runId");
	      //实际步骤号,即现在执行到几步
//	      String prcsIdStr = request.getParameter("prcsId");
      //设计步骤号,即现在执行所在的流程步骤
//	      String flowPrcsStr = request.getParameter("flowPrcs");
	      //用户选择的步骤号(不是实际步骤号),这时步骤号是以逗号分割的(并发时用户可能先多个步骤)，如：2,
	      String prcsChoose = request.getParameter("prcsChoose");
	      YHFlowRunUtility wf = new YHFlowRunUtility();
	      int runId = Integer.parseInt(runIdStr);
//	      int prcsId = Integer.parseInt(prcsIdStr);
	      int flowId = Integer.parseInt(flowIdStr);
//	      int flowPrcs = Integer.parseInt(flowPrcsStr);
//	      YHFlowRunData rd =  wf.getFlowRunData(conn, flowId, runId, "项目部领导审批");	      
//	      String agreeStr = rd.getItemData();
	      
	      this.updateBusinessStatus("gd_content", null, prcsChoose, conn, runIdStr, flowId);

	      
	     
	    } catch(Exception ex) {
	      throw ex;
	    }
	  
    return null;
  }
}
